<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>默认样式信息窗体</title>
    <link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css"/>
    <style>
        html, body, #container {
            height: 100%;
            width: 100%;
        }

        .content-window-card {
            position: relative;
            box-shadow: none;
            bottom: 0;
            left: 0;
            width: auto;
            padding: 0;
        }

        .content-window-card p {
            height: 2rem;
        }

        /*.custom-info {
            border: solid 1px silver;
        }*/

        div.info-top {
            position: relative;
            background: none repeat scroll 0 0 #F9F9F9;
            /*border-bottom: 1px solid #CCC;*/
            border-radius: 5px 5px 0 0;
        }

        div.info-top div {
            display: inline-block;
            color: #333333;
            font-size: 14px;
            font-weight: bold;
            line-height: 31px;
            padding: 0 10px;
        }

        div.info-top img {
            position: absolute;
            top: 5px;
            right: 5px;
            transition-duration: 0.25s;
        }

        div.info-top img:hover {
            box-shadow: 0px 0px 5px #000;
        }

        div.info-middle {
            font-size: 12px;
            padding: 12px 14px;
            line-height: 20px;
        }

        div.info-bottom {
            height: 0px;
            width: 100%;
            clear: both;
            text-align: center;
        }

        div.info-bottom img {
            position: relative;
            z-index: 104;
        }

        span {
            margin-left: 5px;
            font-size: 11px;
        }

        .info-middle img {
            float: left;
            margin-right: 6px;
        }

        /*添加*/
        .three{
            display: inline-block;
            width: 0;
            height: 0;
            border-top: 20px solid #fff;
            border-right: 20px solid transparent;
            position: relative;
            z-index: 104;
        }
    </style>
</head>
<body>
<div id="container"></div>
<script src="https://webapi.amap.com/maps?v=1.4.15&key=6e79f6d236e295632f21b385e363b6e8"></script>
<script type="text/javascript">    //地图初始化时，在地图上添加一个marker标记,鼠标点击marker可弹出自定义的信息窗体
var imageLayer = new AMap.ImageLayer({
    url: './311620451959_.pic_hd.jpg',
    bounds: new AMap.Bounds(
        [121.521445,31.256728],
        [121.735679,31.23354]
    ),
    // zooms: [12, 18]
});

var map = new AMap.Map("container", {
    resizeEnable: true, //是否监控地图容器尺寸变化
    mapStyle: "amap://styles/whitesmoke",
    zoom: 12, //初始地图级别
    center: [121.634055, 31.219888], //初始地图中心点,
    layers: [
        new AMap.TileLayer(),
        imageLayer
    ]
});
addMarker();

//添加marker标记
function addMarker() {
    map.clearMap();
    // 点标记显示内容，HTML要素字符串
    var markerContent = '' +
        '<div class="custom-content-marker">' +
        '   <img src="//a.amap.com/jsapi_demos/static/demo-center/icons/dir-via-marker.png">'
        '</div>';
    var marker = new AMap.Marker({
        map: map,
        position: [121.634055, 31.219888],
        // 将 html 传给 content
        content: markerContent,
    });
    //鼠标点击marker弹出自定义的信息窗体
    AMap.event.addListener(marker, 'click', function () {
        infoWindow.open(map, marker.getPosition());
    });
}

setTimeout(() => {
    map.clearMap();
    // 点标记显示内容，HTML要素字符串
    var markerContent = '' +
        '<div class="custom-content-marker">' +
        '   <img src="//a.amap.com/jsapi_demos/static/demo-center/icons/dir-via-marker.png">'
    '</div>';
    var marker = new AMap.Marker({
        map: map,
        position: [121.634055, 31.219888],
        // 将 html 传给 content
        content: markerContent,
    });
    infoWindow.open(map, marker.getPosition());
})

var infoWindow = new AMap.InfoWindow({
    isCustom: true,  //使用自定义窗体
    content: createInfoWindow(),
    offset: new AMap.Pixel(16, -45)
});


function createInfoWindow() {
    return `
<div class="custom-info input-card content-window-card">
    <div class="info-top">
        <img src="https://webapi.amap.com/images/close2.gif" onclick="closeInfoWindow()">
    </div>
    <div class="info-middle" style="background-color: white; overflow: hidden">
        <div style="float: left;width: 50%">
            <img src="http://tpc.googlesyndication.com/simgad/5843493769827749134" height="160">
        </div>
        <div style="float: left;width: 50%">
        园区名称：北京市朝阳区阜通东大街<br>
        机构资质：010-64733333<br>
        价格：010-64733333<br>
        工位：010-64733333<br>
        面积：010-64733333<br>
        所属产业：010-64733333<br>
        细分领域：- <br>
        联系人：xxx <br>
        联系电话 123123213 <br>
        地址：北京市朝阳区阜通东大街 <br>
        孵化器介绍：北京市朝阳区阜通东大街北京市朝阳区阜通东
        </div>

        <div style="width: 500px;max-width: 100vw"></div>
    </div>
    <div class="info-bottom" style="position: relative; top: 0px; margin: 0px auto;">
        <!--<img src="https://webapi.amap.com/images/sharp.png">-->
        <div class="three"></div>
    </div>
</div>
    `
}

//关闭信息窗体
function closeInfoWindow() {
    map.clearInfoWindow();
}
</script>
</body>
</html>
